package com.wy.allthingdone.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast;

import com.wy.allthingdone.R;
import com.wy.allthingdone.views.PoterDuffLoadingView;

import org.xutils.view.annotation.ViewInject;


public class PreViewActivity extends BaseActivity {
    @ViewInject(R.id.poterDuffLoadingView)
    PoterDuffLoadingView poterDuffLoadingView;
    @ViewInject(R.id.all_ScrollView)
    ScrollView all_ScrollView;
    @ViewInject(R.id.healthyLinearlayout)
    LinearLayout healthyLinearlayout;
    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 1: {
                    if (poterDuffLoadingView != null) {
                        all_ScrollView.setVisibility(View.VISIBLE);
                        poterDuffLoadingView.setVisibility(View.GONE);
                    } else {
                        Toast.makeText(getApplicationContext(), "poterDuffLoadingView===" + poterDuffLoadingView, Toast.LENGTH_SHORT).show();
                    }
                    break;
                }
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_pre_view);
        super.onCreate(savedInstanceState);
        poterDuffLoadingView.setSpeed(4);
//        poterDuffLoadingView = (PoterDuffLoadingView) findViewById(R.id.poterDuffLoadingView);
        all_ScrollView.setVisibility(View.GONE);
        healthyLinearlayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(PreViewActivity.this, BarChartsActivity.class));
            }
        });
        new Thread() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                handler.sendEmptyMessage(1);

            }
        }.start();
    }

}
